<?php

session_start();
?>
<?php require_once('Conection_DataBase.php') ?>
<?php

mysql_select_db(DBNAME, $jssue);
$txtNombre = $_POST['txtNombre'];
$txtNombre2 = $_POST['txtNombre2'];
$pare = "3";
$codMenu = $_SESSION["codCliente"];
$nickName = $_SESSION['nICKbAME'];
$Querry_recordSet3 = "select * from cllg_user where USER_NAME = '$nickName'";
$recordset3 = mysql_query($Querry_recordSet3, $jssue) or die(mysql_error());
$prueba3 = mysql_fetch_assoc($recordset3);
$select = $prueba3['FK_PERFIL'];

$QuerryInsert2 = "Insert Into cllg_menu (TITTLE,URL,MENU_PARENT,ORDEN) values ('$txtNombre', '$txtNombre2', '$pare','$codMenu')";
$Ingre2 = mysql_query($QuerryInsert2, $jssue);
$Querry_recordSet = "select * from cllg_menu order by ID DESC";
$recordset = mysql_query($Querry_recordSet, $jssue) or die(mysql_error());
$prueba = mysql_fetch_assoc($recordset);
$idmenu = $prueba['ID'];
$QuerryUpdate = "Update cllg_menu SET MENU_PARENT = 2 Where ID = '$codMenu'";
$respuesta = mysql_query($QuerryUpdate, $jssue) or die(mysql_error());

$qryPerfiles = "select * from cllg_perfil";
$rsPerfiles = mysql_query($qryPerfiles, $jssue) or die(mysql_error());
while ($perfil = mysql_fetch_assoc($rsPerfiles)) {
    $idPerfil = $perfil["ID"];
    $qryInsertPerfilAccess = "Insert Into cllg_acces (FK_MENU,FK_PERFIL) values ('$idmenu', '$idPerfil')";
    $insertResult = mysql_query($qryInsertPerfilAccess, $jssue);
}

$_SESSION["codCliente"] = "";
Header("Location: Menu1.php?select=$select");
?>